import pymysql  # MySQL 适用

def getUserIdList():
    # 连接数据库
    conn = pymysql.connect(host="localhost", user="root", password="123456", database="esl")
    cursor = conn.cursor()

    # 执行查询（从第 7 条开始）
    query = "SELECT user_id FROM user;"
    # query = "SELECT user_id FROM user limit 500000 offset 38610;"
    cursor.execute(query)

    # 获取数据
    rows = cursor.fetchall()

    # 输出结果
    # for row in rows:
    #     print(row[0],row[1],row[2])

    # 关闭连接
    cursor.close()
    conn.close()
    return rows



if __name__ == "__main__":
    rows = getUserIdList()
    for index,row in enumerate(rows):
        print(index,row)
    print(rows.__len__())


